using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class Member_Shop_MyFavourite : Member, IRequiresSessionState
{
	protected LinkButton LinkButton1;
	protected LinkButton LinkButton2;
	protected Label LabProductCount;
	protected DropDownList DropF_Update;
	protected DropDownList DropF_ProductClassID;
	protected TextBox TxtProductName;
	protected DropDownList DropProductEndDate;
	protected Button Button3;
	protected GridView GridViewProduct;
	protected Button Butdelpro;
	protected DropDownList DropF_ProductClassID1;
	protected Button MoveProductClass;
	protected PlaceHolder PlaceHolder1;
	protected Label LabShopCount;
	protected Label LabSCShopCount;
	protected DropDownList DropF_ShopClassID;
	protected TextBox TxtShopName;
	protected DropDownList DropShopChildID;
	protected Button Button7;
	protected GridView GridViewShop;
	protected Button DelShop;
	protected DropDownList DropF_ShopClassID1;
	protected Button MoveShopClass;
	protected PlaceHolder PlaceHolder2;
	protected PlaceHolder PlaceHolder3;
	protected ObjectDataSource productFavouriteDatasource;
	protected ObjectDataSource ShopmyFavouriteDataSource;
	private int UserID = 0;
	public string m_flag = "0";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.UserID = base.user.UserID;
		this.ShopmyFavouriteDataSource.SelectParameters["F_UserID"].DefaultValue = this.UserID.ToString();
		this.productFavouriteDatasource.SelectParameters["F_UserID"].DefaultValue = this.UserID.ToString();
		if (!base.IsPostBack)
		{
			this.BandFProductClass();
			this.BandFShopClass();
			this.BandShopClass();
			if (base.Request["tag"] != null)
			{
				if (base.Request["tag"].ToString().Trim() == "0")
				{
					this.m_flag = "0";
					this.PlaceHolder1.Visible = true;
					this.PlaceHolder2.Visible = false;
					this.PlaceHolder3.Visible = false;
					Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite();
					this.LabProductCount.Text = shop_MyFavourite.GetAllProductCount(this.UserID).ToString();
				}
				if (base.Request["tag"].ToString().Trim() == "1")
				{
					this.m_flag = "1";
					this.PlaceHolder2.Visible = true;
					this.PlaceHolder1.Visible = false;
					this.PlaceHolder3.Visible = false;
					Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite(this.conn);
					this.LabShopCount.Text = shop_MyFavourite.GetAllShopCount(this.UserID).ToString();
					this.LabSCShopCount.Text = shop_MyFavourite.GetShopCountByClassID(this.UserID, int.Parse(this.DropF_ShopClassID.SelectedValue)).ToString();
					if (base.Request["SValue"] != null && base.Request["SValue"].ToString() != "")
					{
						this.DropF_ShopClassID.SelectedValue = base.Request["SValue"].ToString();
					}
				}
			}
			else
			{
				this.PlaceHolder1.Visible = true;
				this.PlaceHolder2.Visible = false;
				this.PlaceHolder3.Visible = false;
				Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite(this.conn);
				this.LabProductCount.Text = shop_MyFavourite.GetAllProductCount(this.UserID).ToString();
			}
			ShopConfigBll shopConfigBll = new ShopConfigBll();
			DataTable config = shopConfigBll.GetConfig();
			if (!config.Rows[0]["ShowShop"].ToString().Equals("1"))
			{
				this.LinkButton2.Visible = false;
			}
			config.Dispose();
		}
	}
	protected void BandFProductClass()
	{
		ListItem listItem = new ListItem();
		listItem.Text = "所有";
		listItem.Value = "0";
		Shop_FProductClass shop_FProductClass = new Shop_FProductClass(this.conn);
		DataTable fProductClassByUserID = shop_FProductClass.GetFProductClassByUserID(this.UserID);
		this.DropF_ProductClassID.DataSource = (this.DropF_ProductClassID1.DataSource = fProductClassByUserID);
		this.DropF_ProductClassID.DataTextField = (this.DropF_ProductClassID1.DataTextField = "F_ProductClassName");
		this.DropF_ProductClassID.DataValueField = (this.DropF_ProductClassID1.DataValueField = "F_ProductClassID");
		this.DropF_ProductClassID.DataBind();
		this.DropF_ProductClassID1.DataBind();
		ListItem listItem2 = new ListItem();
		listItem2.Value = "-1";
		listItem2.Text = Language.Get("Common/NoClass");
		this.DropF_ProductClassID.Items.Add(listItem2);
		this.DropF_ProductClassID1.Items.Add(listItem2);
		this.DropF_ProductClassID.Items.Insert(0, listItem);
		this.DropF_ProductClassID.Items[0].Selected = true;
	}
	protected void BandFShopClass()
	{
		ListItem listItem = new ListItem();
		listItem.Text = "所有";
		listItem.Value = "0";
		Shop_FShopClass shop_FShopClass = new Shop_FShopClass(this.conn);
		DataTable fShopClassByUserID = shop_FShopClass.GetFShopClassByUserID(this.UserID);
		this.DropF_ShopClassID.DataSource = fShopClassByUserID;
		this.DropF_ShopClassID1.DataSource = fShopClassByUserID;
		this.DropF_ShopClassID.DataTextField = (this.DropF_ShopClassID1.DataTextField = "F_ShopClassName");
		this.DropF_ShopClassID.DataValueField = (this.DropF_ShopClassID1.DataValueField = "F_ShopClassID");
		this.DropF_ShopClassID.DataBind();
		this.DropF_ShopClassID1.DataBind();
		ListItem listItem2 = new ListItem();
		listItem2.Value = "-1";
		listItem2.Text = Language.Get("Common/NoClass");
		this.DropF_ShopClassID.Items.Add(listItem2);
		this.DropF_ShopClassID1.Items.Add(listItem2);
		this.DropF_ShopClassID.Items.Insert(0, listItem);
		this.DropF_ShopClassID.Items[0].Selected = true;
	}
	protected void BandShopClass()
	{
		Shop_Class shop_Class = new Shop_Class(this.conn);
		DataTable rootClass = shop_Class.GetRootClass();
		foreach (DataRow dataRow in rootClass.Rows)
		{
			string text = dataRow["ClassName"].ToString();
			string value = dataRow["ClassID"].ToString();
			if (text != "")
			{
				if (!(text == "服务商品") && !(text == "创美商品"))
				{
					ListItem item = new ListItem(text, value);
					this.DropShopChildID.Items.Add(item);
				}
			}
		}
		ListItem item2 = new ListItem("所有", "-1");
		this.DropShopChildID.Items.Insert(0, item2);
		this.DropShopChildID.DataBind();
	}
	protected void IComplain_SelectType(object sender, CommandEventArgs e)
	{
		string commandName = e.CommandName;
		if (commandName != null)
		{
			if (!(commandName == "flag1"))
			{
				if (!(commandName == "flag2"))
				{
					if (commandName == "flag3")
					{
						this.PlaceHolder1.Visible = false;
						this.PlaceHolder3.Visible = true;
						this.PlaceHolder2.Visible = false;
					}
				}
				else
				{
					this.m_flag = "1";
					this.PlaceHolder1.Visible = false;
					this.PlaceHolder2.Visible = true;
					this.PlaceHolder3.Visible = false;
					Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite(this.conn);
					this.LabShopCount.Text = shop_MyFavourite.GetAllShopCount(this.UserID).ToString();
					this.LabSCShopCount.Text = shop_MyFavourite.GetShopCountByClassID(this.UserID, int.Parse(this.DropF_ShopClassID.SelectedValue)).ToString();
				}
			}
			else
			{
				this.m_flag = "0";
				this.PlaceHolder1.Visible = true;
				this.PlaceHolder2.Visible = false;
				this.PlaceHolder3.Visible = false;
				Shop_MyFavourite shop_MyFavourite2 = new Shop_MyFavourite(this.conn);
				this.LabProductCount.Text = shop_MyFavourite2.GetAllProductCount(this.UserID).ToString();
			}
		}
	}
	protected void DropF_ProductClassID_SelectedIndexChanged(object sender, EventArgs e)
	{
		Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite(this.conn);
	}
	protected void Button3_Click(object sender, EventArgs e)
	{
		this.Page.Response.Redirect("Shop_ManageFProductClass.aspx");
	}
	protected void Button7_Click(object sender, EventArgs e)
	{
		this.Page.Response.Redirect("Shop_ManageFShopClass.aspx");
	}
	protected void DropF_ShopClassID_SelectedIndexChanged(object sender, EventArgs e)
	{
		Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite(this.conn);
		this.LabSCShopCount.Text = shop_MyFavourite.GetShopCountByClassID(this.UserID, int.Parse(this.DropF_ShopClassID.SelectedValue)).ToString();
		this.m_flag = "1";
	}
	protected void DropShopChildID_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.ShopmyFavouriteDataSource.SelectParameters["ShopChildID"].DefaultValue = this.DropShopChildID.SelectedValue;
		this.m_flag = "1";
	}
	public string GetDropF_ShopClassID()
	{
		return this.DropF_ShopClassID.SelectedValue;
	}
	protected void FavButtonClick(object sender, CommandEventArgs e)
	{
		Shop_MyFavourite shop_MyFavourite = new Shop_MyFavourite(this.conn);
		string text = Text.CheckNumList(base.Request["cb_id"]);
		if (text != null && text != "")
		{
			string commandName = e.CommandName;
			if (commandName != null)
			{
				if (!(commandName == "del_product"))
				{
					if (!(commandName == "del_shop"))
					{
						if (!(commandName == "move_shop"))
						{
							if (commandName == "move_product")
							{
								shop_MyFavourite.MoveFProductClass(int.Parse(this.DropF_ProductClassID1.SelectedValue), text);
								this.GridViewProduct.DataBind();
							}
						}
						else
						{
							shop_MyFavourite.MoveFShopClass(int.Parse(this.DropF_ShopClassID1.SelectedValue), text);
							this.GridViewShop.DataBind();
						}
					}
					else
					{
						Shop_MyFavourite shop_MyFavourite2 = new Shop_MyFavourite(this.conn);
						if (shop_MyFavourite.DeleteMyFavourite(text))
						{
							this.GridViewShop.DataBind();
						}
						this.LabShopCount.Text = shop_MyFavourite2.GetAllShopCount(this.UserID).ToString();
						this.LabSCShopCount.Text = shop_MyFavourite2.GetShopCountByClassID(this.UserID, int.Parse(this.DropF_ShopClassID.SelectedValue)).ToString();
					}
				}
				else
				{
					if (shop_MyFavourite.DeleteMyFavourite(text))
					{
						this.GridViewProduct.DataBind();
						this.conn.Execute("Update HLShop_Product set FavouriteNum=FavouriteNum-1 where ProductID in(" + text + ")");
					}
				}
			}
		}
		else
		{
			if (e.CommandName == "del_shop" || e.CommandName == "move_shop")
			{
				this.WriteErrMsg("", "未选中店铺信息项，请您选择店铺信息项！", "");
			}
			if (e.CommandName == "del_product" || e.CommandName == "move_product")
			{
				this.WriteErrMsg("", "未选中商品信息项，请您选择商品信息项！", "");
			}
		}
		if (e.CommandName == "del_shop")
		{
			this.m_flag = "1";
		}
	}
}
